package com.example.mform.controller;

import com.example.mform.entity.UserForm;
import com.example.mform.service.UserFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shishuqian
 * date 2020/11/24
 * time 14:45
 **/
@RestController
@RequestMapping("/userForm")
public class UserFormController {

    @Autowired
    private UserFormService userFormService;

    @GetMapping("/findAll")
    public List<UserForm> findAll(){
        return userFormService.findAll();
    }

    @GetMapping("/findByPage/{page}/{size}")
    public Page<UserForm> findByPage(@PathVariable("page") Integer page,@PathVariable("size") Integer size){
        return userFormService.findByPage(page,size);
    }

    @GetMapping("/findById/{id}")
    public UserForm findById(@PathVariable("id") Long id){
        return userFormService.findById(id);
    }

    @PostMapping("/save")
    public void save(@RequestBody UserForm userForm){
        userFormService.save(userForm);
    }

    @PutMapping("/update")
    public void update(@RequestBody UserForm userForm){
        userFormService.save(userForm);
    }

    @DeleteMapping("/deleteById/{id}")
    public void  deleteById(@PathVariable("id") Long id){
        userFormService.deleteById(id);
    }

    @PutMapping("/releaseOrStop/{id}")
    public void release(@PathVariable("id") Long id){
        userFormService.release(id);
    }

}
